<template>
  <div class="newsinfo-container">
    <!-- 大标题 -->
    <h3 class="title">{{listinfo.title}}</h3>
    <!-- 子标题 -->
    <p class="subtitle">
      <span>发表时间:{{listinfo.add_time}}</span>
      <span>点击:{{listinfo.click}}次</span>
    </p>
    <hr>
    <!-- 内容 -->
    <div class="content" v-html="listinfo.content"></div>
    <!-- 评论组件 -->
    <comment-box :id="this.id"></comment-box>
  </div>
</template>

<script>
import api from "../../../aaa_lianxi/mock_newsinfo.js";
import comment from "../subcomponents/comment.vue";
export default {
  components: {
    "comment-box": comment
  },
  data() {
    return {
      id: this.$route.params.id,
      listinfo: {}
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("/news/newsinfo").then(
        res => {
          if (res.status === 200) {
            this.listinfo = res.body.articles[0];
          }
        },
        err => {
          console.log(err.message);
        }
      );
    }
  }
};
</script>
<style lang="scss" scoped>
.newsinfo-container {
  padding: 0 3px;
  .title {
    font-size: 16px;
    text-align: center;
    margin: 15px, 0;
    color: red;
  }
  .subtitle {
    font-size: 13px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
  .content {
    font-size: 14px;
  }
}
</style>
